//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

public class demo_860 {
    public demo_860() {
    }

    public boolean lemonadeChange(int[] bills) {
        int five = 0;
        int ten = 0;

        for(int bill : bills) {
            if (bill == 5) {
                ++five;
            } else if (bill == 10) {
                if (five == 0) {
                    return false;
                }

                --five;
                ++ten;
            } else if (ten != 0 && five != 0) {
                --ten;
                --five;
            } else {
                if (five < 3) {
                    return false;
                }

                five -= 3;
            }
        }

        return true;
    }
}
